<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="姓名">
        <el-input v-model="form.pname"></el-input>
      </el-form-item>
      <el-form-item label="年龄">
        <el-input v-model="form.age"></el-input>
      </el-form-item>
      <el-form-item label="员工号">
        <el-input v-model="form.eID"  :disabled='true'></el-input>
      </el-form-item>
      <el-form-item label="职务">
        <el-select v-model="form.role" placeholder="请选择职务">
          <el-option label="配送员" value="配送员"></el-option>
          <el-option label="客服" value="客服"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="入职日期">
        <el-col :span="11">
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="form.date"
            style="width: 100%"
          ></el-date-picker>
        </el-col>
      </el-form-item>

      <el-form-item label="性别">
        <el-radio-group v-model="form.sex">
          <el-radio label="男"></el-radio>
          <el-radio label="女"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="薪资">
        <el-input-number v-model="form.money" :step="100"></el-input-number>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认</el-button>
        <el-button @click="reset">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import axios from 'axios';
import qs from 'qs'
export default {
  data() {
    return {
      form: {
        pname: "",
        date: "",
        sex: "",
        age: "",
        role: "",
        money: "",
        eID:""
      },
      
    };
  },
  methods: {
    onSubmit() {
        axios({
        url:'http://localhost:3000/editEmp',
        method:'post',
        data:qs.stringify(this.form)
      })
      history.back()
    },
    reset(){
      this.$router.push('/employee')
    }
  },
  mounted(){
    axios({
      url:'http://localhost:3000/employeeInfo',
      method:"get",
      params:{
        id:this.$route.query.i
      }
    }).then((success)=>{
      this.form=success.data[0]
    })
  }
};
</script>

<style scoped>
</style>